package com.jar.exercise.设计模式.visitor模式.双分派;


public class DoubleDispatch {
    public static void main(String[] args) {
        OutPut outPut = new OutPut();
        People people = new People();
        People student = new Student();
        People teacher = new Teacher();
        people.accept(outPut);
        student.accept(outPut);
        teacher.accept(outPut);
    }
}
class OutPut{
    void print(Teacher teacher) {
        System.out.println("我是老师");
    }
    void print(Student student) {
        System.out.println("我是学生");
    }
    void print(People student) {
        System.out.println("我是人");
    }


}

class People{
    void accept(OutPut outPut) {
        outPut.print(this);
    }
}

class Teacher extends People  {
    void accept(OutPut outPut) {
        outPut.print(this);
    }
}

class Student extends People{
    void accept(OutPut outPut) {
        outPut.print(this);
    }
}